// qr project main.go
package main

import (
	"bytes"
	"code.google.com/p/rsc/qr"
	"fmt"
	"image"
	"image/png"
	"os"
)

func main() {
	code, err := qr.Encode("nihao", qr.L)
	if err != nil {
		fmt.Println(err)
		return
	}
	pngbyte := code.PNG()
	fmt.Println("Hello World!", pngbyte)
	img, _, _ := image.Decode(bytes.NewReader(pngbyte))
	out, err := os.Create("./QRImg.png")
	if err != nil {
		fmt.Println(err)
		return
	}

	err = png.Encode(out, img)

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	// everything ok
	fmt.Println("QR code generated and saved to QRimg1.png")

}
